package com.agung.wonogirimaps;

import com.agung.wonogirimaps.adapter.TwoListItemAdapter;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class MainActivity extends ActionBarActivity implements
		OnItemClickListener
{

	// array untuk menu utama
	private final String[]		menuTitle		= { "Wisata Unggulan",
			"Daftar Hotel", "Daftar Rumah Makan", "Cara Penggunaan",
			"Tentang Wonogiri"					};
	// array untuk icon menu
	private final int[]			menuThumbImg	= { R.drawable.ic_launcher,
			R.drawable.ic_launcher, R.drawable.ic_launcher,
			R.drawable.ic_launcher, R.drawable.ic_launcher };

	private TwoListItemAdapter	adapter;

	// listview pada menu utama
	private ListView			listMenu;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		// set layout ke acitivity_main.xml
		setContentView(R.layout.activity_main);

		listMenu = (ListView) findViewById(R.id.listMenu);
		listMenu.setOnItemClickListener(this);

		// set agar actionbar tidak menampilkan icon
		// hanya berupa text saja
		getSupportActionBar().setIcon(android.R.color.transparent);

		adapter = new TwoListItemAdapter(getApplicationContext(), menuTitle,
				menuThumbImg, R.layout.single_list_item_menu, R.id.thumbMenu,
				R.id.titleMenu);
		// tampilkan menu kedalam listview, set adapternya
		listMenu.setAdapter(adapter);

	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int position,
			long arg3)
	{
		switch (position)
		{
			case 0:
				startActivity(new Intent(this, LocationActivity.class));
				// startActivity(new Intent(this, CategoryActivity.class));

				break;
			case 1:
				startActivity(new Intent(this, HotelActivity.class));

				break;
			case 2:
				startActivity(new Intent(this, RumahMakanActivity.class));
				break;
			case 3:
				startActivity(new Intent(this, TentangActivity.class));
				break;

		}
		finish();
	}
}
